#ifndef __UM_SERVER_H__
#define __UM_SERVER_H__

#include "um_basic_types.h"
#include "umapi_os_list.h"
#include "umUfd.h"
#include "serverConfig.h"

typedef struct Server
{
	UM_S32 (*init)(UM_VOID* pServer, struct umapi_list_head *params);
	UM_VOID* (*start)(UM_VOID* pServer,UM_CHAR *src, UM_CHAR *dest);
	UM_S32 (*stop)(UM_VOID* pServer,UM_VOID* pTranscode);
	UM_VOID (*destroy)(UM_VOID* pServer);
	UM_CHAR * (*getUrl)(UM_VOID* pServer);
	UM_CHAR * (*toString)(UM_VOID* pServer);
	UM_BOOL (*match)(UM_CHAR *protol);
	UM_VOID *(*create)();
}Server;



typedef enum
{
	HTTP,
	PROXY,
	AO,
	FFMPEG,
	MEM,
	RTMP,
	P2P,
}E_MEDIA_SERVERTYPE;

typedef enum
{
	TRACE,
	INFO,
	WARN,
	ERR,
}E_LOG_LEVEL;

typedef struct
{
	Server sever;
	UM_S32 logLevel;
	UM_HANDLE logFd;
	UM_HANDLE fd;
	UM_CHAR id[20];
	UM_CHAR codeType[20];
	UM_S32 port;
	UM_S32 maxClientCount;
	E_MEDIA_SERVERTYPE mt;
	struct umapi_list_head head;
}ServerContext;

extern Server umProxy;
extern Server umAo;
extern Server umFfmpeg;
extern Server umRtmp;
extern Server umRtmp2;
extern Server umP2p;

#define MUPROCESS 0
#define DEAMONPROCESS 0


#define SPACE_CHARS " \t\r\n"
UM_S32 startServerListen(ServerContext *s, UM_BOOL isNBIO);
UM_VOID createRandomStr(UM_CHAR *pbuff, UM_S32 len);
UM_CHAR * serverToString(Server* s);

#define DEBUG(fmt, arg...) printf("[%s.%d]"fmt"\n",__FUNCTION__,__LINE__,##arg)

#endif
